/**
 * 文件名：MySingleExecutor.java
 *
 * 创建人：Elvin Zhao - 279152260@qq.com
 *
 * 创建时间：2019年5月23日 下午4:04:07
 *
 * 版权所有：FNII
 */
package com.z100h.supplychain.common.service;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

import org.springframework.stereotype.Component;

/**
 * [描述信息：说明类的基本功能]
 *
 * @author Elvin Zhao - 279152260@qq.com
 * @version 1.0 Created on 2019年5月23日 下午4:04:07
 */
@Component
public class MySingleExecutor {

	private final ExecutorService executor = Executors.newSingleThreadExecutor(new ThreadFactory() {

		@Override
		public Thread newThread(Runnable runnable) {
			return new Thread(runnable, "MySingleExecutor");
		}
	});

	public void execute(Runnable runnable) {
		this.executor.execute(runnable);
	}

	public void destroy() {
		this.executor.shutdown();
	}
}
